using System;

namespace KartRider.IO.Packet
{
	public class CryptoConstants
	{
		public static byte[] specKeys1;

		public static byte[] specKeys2;

		public static uint[] ThirdByte_Keys;

		public static uint[] SecondByte_Keys;

		public static uint[] FirstByte_Keys;

		public static uint[] ZeroByte_Keys;

		static CryptoConstants()
		{
			CryptoConstants.specKeys1 = new byte[] { 79, 200, 44, 182, 173, 43, 108, 229, 46, 65, 174, 137, 154, 120, 126, 207, 91, 124, 189, 116, 251, 220, 5, 239, 42, 167, 225, 205, 215, 90, 41, 45, 13, 4, 245, 231, 180, 133, 208, 59, 178, 20, 110, 150, 219, 99, 203, 243, 141, 160, 81, 195, 31, 78, 228, 57, 181, 121, 76, 170, 21, 143, 240, 37, 222, 9, 152, 138, 113, 56, 254, 27, 100, 75, 62, 52, 107, 69, 25, 196, 123, 30, 193, 39, 19, 197, 36, 11, 128, 80, 230, 29, 32, 145, 58, 209, 176, 50, 129, 244, 147, 102, 112, 151, 97, 70, 40, 168, 96, 83, 190, 86, 2, 51, 177, 217, 172, 105, 118, 38, 210, 206, 201, 183, 1, 248, 74, 17, 246, 139, 22, 164, 55, 185, 67, 237, 159, 3, 184, 212, 235, 156, 117, 162, 142, 214, 33, 127, 48, 213, 136, 211, 26, 194, 199, 169, 161, 134, 89, 227, 140, 87, 10, 144, 77, 247, 187, 125, 82, 241, 23, 103, 16, 95, 192, 85, 6, 68, 149, 66, 165, 8, 253, 61, 157, 224, 0, 166, 92, 7, 179, 255, 73, 49, 242, 236, 54, 153, 104, 202, 115, 64, 111, 28, 233, 53, 72, 232, 171, 252, 135, 101, 18, 146, 98, 71, 221, 148, 24, 234, 198, 114, 163, 109, 106, 249, 84, 186, 238, 94, 223, 155, 132, 175, 60, 88, 226, 35, 122, 15, 34, 63, 204, 158, 218, 14, 130, 131, 191, 188, 93, 47, 216, 119, 250, 12, 196, 37, 144, 0, 0, 0, 0, 0 };
			CryptoConstants.specKeys2 = new byte[] { 186, 124, 112, 137, 33, 22, 176, 189, 181, 65, 162, 87, 255, 32, 245, 239, 172, 127, 212, 84, 41, 60, 130, 170, 218, 78, 152, 71, 203, 91, 81, 52, 92, 146, 240, 237, 86, 63, 119, 83, 106, 30, 24, 5, 2, 31, 8, 251, 148, 193, 97, 113, 75, 205, 196, 132, 69, 55, 94, 39, 234, 183, 74, 241, 201, 9, 179, 134, 177, 77, 105, 215, 206, 192, 126, 73, 58, 164, 53, 0, 89, 50, 168, 109, 226, 175, 111, 161, 235, 158, 29, 16, 188, 250, 229, 173, 108, 104, 214, 45, 72, 211, 101, 171, 198, 117, 224, 76, 6, 223, 42, 202, 102, 68, 221, 200, 19, 142, 118, 253, 13, 57, 238, 80, 17, 167, 14, 147, 88, 98, 246, 247, 232, 37, 157, 210, 150, 11, 67, 129, 160, 48, 144, 61, 163, 93, 213, 100, 217, 178, 43, 103, 66, 197, 12, 231, 141, 184, 243, 136, 49, 156, 143, 222, 131, 180, 187, 25, 107, 155, 59, 208, 116, 4, 10, 233, 96, 114, 40, 190, 36, 56, 3, 123, 138, 133, 227, 166, 249, 18, 110, 248, 174, 82, 153, 51, 79, 85, 220, 154, 1, 122, 199, 46, 242, 27, 121, 15, 38, 95, 120, 151, 139, 149, 145, 28, 252, 115, 244, 44, 21, 216, 64, 230, 185, 26, 236, 159, 54, 7, 90, 35, 207, 204, 219, 140, 195, 135, 228, 23, 62, 169, 194, 47, 99, 34, 128, 165, 125, 225, 254, 20, 209, 182, 70, 191 };
			CryptoConstants.ThirdByte_Keys = new uint[] { 990685351, 3817408038, 2780417155, 3648157507, 1676167516, 636118092, 1345440942, 3368027300, 3953004261, 2270839896, 359779047, 2850759413, 3315972108, 3422906710, 558406616, 4131400947, 4263647690, 4002025643, 1309038711, 3414891590, 1354587019, 3100014252, 2672459854, 963694860, 47972109, 1172263679, 1640169200, 642429312, 3295692143, 823954549, 2305637600, 844822004, 336176240, 1283095007, 3336465230, 2192263565, 508720502, 871611436, 4234909339, 478709248, 3751833154, 2893032882, 3346661374, 1038683449, 3978114023, 2636629938, 2472697484, 2786295597, 695904887, 3627327837, 206457334, 3138154682, 252348829, 3285063913, 1787004349, 3664962836, 2096085483, 2680314657, 1998444182, 3890604637, 3027011700, 688113102, 3832533232, 1998307394, 2052034208, 2732583009, 246067737, 3406697528, 2610787122, 3379245347, 4098905775, 2467991394, 2183659936, 2424894264, 2825504946, 3054114303, 4187965439, 3148243257, 1876982515, 2906880567, 1905349969, 3761535704, 628000093, 1150642730, 2261330672, 1424248583, 1881125930, 1518147151, 96576077, 3397271058, 2691286880, 2119469696, 113598694, 2265489628, 842872568, 26506517, 3989912137, 816887151, 935275155, 2867027776, 709135393, 421512668, 187890863, 2666027315, 2592647480, 749947710, 4208457976, 475158715, 2505868283, 2853035673, 3238562268, 3167671155, 4199949961, 2901741559, 430469014, 1111033302, 3080557286, 1162992787, 1611138389, 2503088125, 2447918889, 2121730776, 3576168699, 3689061689, 3164621491, 2474572562, 3302613200, 3994510645, 3004322070, 3737125728, 1962539738, 1532881795, 3703348860, 3486732989, 2374368669, 3906017615, 3159095837, 2504222223, 393343441, 465021017, 3950776795, 481112752, 2521086986, 153181479, 3973228140, 2125035161, 1006582964, 3658161059, 2151600959, 1157176317, 1490505098, 1455201450, 3850615380, 293113271, 3177834718, 2104998164, 2378059596, 1199976697, 2418659320, 2319490534, 1882425632, 3959669986, 1432208920, 3535095632, 132044585, 3859190770, 1669095567, 178923337, 4292879320, 496484520, 2129654366, 1372675872, 2750192147, 3275326295, 2866176260, 455185505, 4151564543, 2635181000, 1754955986, 2397627325, 2314054272, 2651383093, 2166381700, 407807836, 2507289246, 2499309535, 1832927250, 238545439, 2383658931, 2192777044, 3468288829, 1422860145, 2825934462, 3556887835, 1698297278, 271542445, 3461268938, 299818910, 2682218376, 2555098616, 3474409209, 3835673796, 1090001123, 2423653801, 855462623, 2309279076, 1864782611, 3262722074, 1791105955, 3567238470, 1124811847, 765645313, 4085506910, 2514568779, 1756579969, 3168186558, 269890522, 2537278472, 4230874910, 2611737342, 2991866954, 4162164733, 3690817971, 1121028542, 2279913558, 3065780578, 2684468532, 153544813, 1995397060, 3266151985, 231400673, 2996305904, 2558005572, 4059982330, 3672748954, 1896422142, 2123631560, 2025179922, 1612621306, 3127892520, 2364308393, 3902219752, 1484347347, 2637366522, 193980768, 2763262726, 3795679521, 1377885408, 92204739, 1160561528, 2228376594, 3547852830, 3508065379, 4118642277, 4291283439, 3342538584 };
			CryptoConstants.SecondByte_Keys = new uint[] { 68991385, 526532244, 2526318983, 4074936836, 251318069, 1393743729, 1213090431, 1962883870, 2073281660, 2682625237, 2235658529, 4291542149, 3298009539, 4137377780, 2680857763, 2577504365, 2585658712, 391104297, 2860780138, 1179567361, 4250018237, 307477156, 1488846456, 910898745, 2753591204, 2514269486, 3161027602, 3104588120, 549159283, 3891196712, 1410668323, 2093180971, 2343253148, 927759012, 3825480377, 3617006263, 3942796895, 4213216620, 1822726507, 3155048427, 4066669120, 2219659600, 2641066393, 673263335, 3441424756, 440135943, 2078609390, 3931410312, 277672005, 3641402857, 1110393974, 3325539497, 2397308820, 3983697196, 3728352220, 4024867822, 1736398658, 1599401014, 976690026, 754948884, 1228108660, 3126605887, 95371938, 836108259, 4168271218, 2459723282, 2528907725, 875534369, 2727265841, 1853338728, 4038165811, 349439548, 2389574882, 512764798, 937322611, 1543801902, 2427122692, 909087755, 3148928503, 2200268920, 3432855689, 2954292601, 4293214560, 1905607796, 3591390404, 247160569, 1624205075, 3167094051, 2997125540, 4005802553, 2102618041, 2688308532, 929360733, 837895476, 1464234355, 37995600, 2515936024, 790856770, 157537748, 3850540500, 1198511997, 1590184104, 1964793294, 1511928049, 931198746, 3876716866, 3891455874, 2615234684, 2547996750, 2740135445, 916308950, 2106519051, 1607065799, 4239422779, 4011433041, 2688080119, 311489827, 379888127, 2069223186, 3372145743, 2212097256, 1230490834, 3323909079, 609471807, 57507715, 3811272393, 174926372, 69329168, 1028147823, 1990482464, 2811419979, 4242306510, 750987694, 1223511117, 1774953207, 114864146, 963845191, 2562995518, 2208405464, 1348981207, 1352474349, 1638957415, 3984014733, 3275831710, 3462056116, 1484310779, 1246087621, 942330471, 121096981, 1868452956, 3047725046, 1153013590, 3540968300, 1431065733, 2862059718, 2617894010, 1736971326, 1252958033, 2220667690, 1722522016, 2386550172, 1298937087, 3372373633, 1783891268, 3848361770, 2030640771, 3778719649, 2011505422, 1853074758, 2080868333, 521038421, 3970747141, 2615778500, 1983615056, 3160406701, 1772280874, 3356394712, 393997452, 2551703327, 3561577947, 1113742532, 1094688954, 1378525983, 4079289191, 769445801, 4059395191, 2923319299, 1607643742, 990477363, 3553036582, 19420232, 438911287, 1922809389, 2382247967, 1131973675, 2447644212, 2237984830, 3928291769, 583145762, 3779453227, 1214070317, 2405201572, 406014545, 3624288373, 2399469442, 787894266, 425104857, 4076527394, 3091248323, 424423682, 25717394, 3552275240, 1358496527, 2347694319, 3025052140, 672221337, 2896010857, 1183664959, 438878076, 2499608325, 654302346, 271149415, 2100585754, 1558684028, 1638807023, 2782673210, 839562881, 2586973977, 1568198025, 1153045026, 3698876939, 187521307, 1007689615, 4291325204, 4187191288, 3021132085, 1328145094, 949257115, 3710627609, 1205521749, 1766851989, 2619541479, 721975080, 2550886472, 3994055474, 2016147303, 895350931, 1049310824, 791827290, 1653055102, 3483864298, 3877078855, 3318905331, 3630152715, 3239148266, 3232357104 };
			CryptoConstants.FirstByte_Keys = new uint[] { 4181631060, 47417776, 1757478942, 3817329965, 1560940818, 3142495404, 2508309135, 2967432282, 1386236851, 3794408196, 3429053971, 5996427, 3925920555, 2480383980, 2272005648, 3146488764, 341456675, 1104227971, 2326084750, 2766999750, 1443444869, 2264555454, 881431276, 3163419123, 2547672739, 2201076626, 505695535, 3829505432, 666893565, 2209185137, 437411811, 334690526, 645413089, 2322840079, 3523063969, 4150953035, 1535639299, 2950597294, 825807068, 396195771, 1201932454, 3165595645, 1934031957, 3015587333, 2776513451, 1444292422, 1874510995, 734521941, 2777702029, 4206164477, 1124817702, 4049963616, 4095694648, 744741431, 2184245910, 633910251, 2342946596, 2267197151, 4285150696, 3168148534, 3152646560, 2569762923, 2272146211, 3856254697, 3471723864, 2931431626, 999085810, 2922252747, 1086226044, 31305698, 118025945, 430895621, 1886065097, 2211614154, 3072713206, 1795644849, 1198469185, 1860538734, 2175555335, 3973841469, 3223652521, 473450783, 2767753397, 3247635055, 3700221316, 2109341973, 1447642835, 3095191104, 1994681836, 4049865719, 362914443, 3768656669, 3307941798, 1653498822, 3271011717, 2278175336, 3272256157, 367874350, 1982105250, 3974887957, 1252597193, 2446058114, 519755358, 2769213634, 194604088, 1897069666, 3949494183, 2444689095, 822224930, 2693077371, 674502832, 1682824772, 4184773274, 786268422, 2120371978, 2939165824, 300329374, 1280086517, 1903706390, 2136877956, 1751803107, 3450272911, 1394539891, 2015821016, 918729577, 3270067250, 1282665859, 3809619628, 2825798977, 2799334771, 3810947720, 1696932716, 2244729217, 1768922263, 3247762661, 4272827329, 3448264938, 3351053890, 43200102, 1427094919, 3774216897, 2816185752, 1297573767, 1907383725, 2081786939, 1606016604, 3735683300, 1853931798, 3631212503, 2331110477, 594705877, 1446954294, 848740229, 164523662, 1522372080, 1798222740, 1781497146, 3681115413, 1363115473, 1189715765, 582758679, 326337290, 2889091778, 3756669154, 2006538245, 1902252616, 1531366426, 3800550998, 1621036151, 1021672012, 2475442978, 826923317, 4105006746, 3840995050, 2625635870, 607328449, 1063980086, 3835404277, 2064790403, 1911651972, 2627193251, 3921064175, 3132359406, 2812930290, 3861077646, 769003807, 2445902431, 384710439, 2280055772, 1129519812, 1714457423, 3820394937, 3207023353, 2599497051, 825560403, 3913538171, 3894846137, 3006821722, 434854984, 364402715, 2570203150, 2811331519, 640878, 3872849084, 2858460161, 2840641518, 3456548872, 3211901691, 405033398, 3182943871, 4244371226, 2922610770, 1411339617, 1479544314, 4171485374, 86316091, 3392929540, 2190062385, 1080764032, 3196137586, 3048652908, 4109807017, 1025450618, 1814731735, 2490825851, 2864863526, 1163884565, 1595281213, 3408331195, 615364325, 2766655976, 3142192623, 3092705583, 4206570809, 461473125, 3557859314, 2845124748, 318211766, 326698961, 1848963278, 3817411904, 4188264546, 3294893021, 1157463794, 21830237, 2068286196, 3559314781, 844924981, 3794806926, 2139348922, 2039725338, 1021549835, 2967854946, 4251893843, 1460143923, 3698525709 };
			CryptoConstants.ZeroByte_Keys = new uint[] { 698093334, 4153209025, 687329636, 1330254401, 3916106625, 2952421312, 4104853545, 342297114, 3849582276, 594759519, 3972706581, 3813314319, 2546473586, 2745643552, 15292858, 359052952, 2648217043, 2296540034, 650215534, 480030859, 3486473202, 3251391348, 2341285349, 1648238562, 957865264, 230415491, 1176551027, 1334224241, 2049672829, 963654108, 1832923131, 418379265, 302181290, 2837768150, 3919102800, 2472387261, 2408932129, 2834486529, 722309581, 385394533, 3323963752, 374371742, 2865252492, 3395534059, 3903329902, 1562257198, 1353058821, 570194068, 2744804230, 3455760427, 1950516124, 3076488623, 3621414904, 2324290484, 3207667468, 2814379519, 2098869167, 1790116637, 2313721741, 1460238820, 104826264, 4173353579, 2177892388, 1745874687, 3847153305, 2341433717, 951194773, 1015501097, 1769704939, 3626945938, 358472393, 3109202619, 2532315582, 3258639444, 3115954683, 3921353904, 2909718235, 3533454938, 1414711068, 2634845840, 3824536475, 4006059241, 36821267, 1292660696, 509272341, 2760497346, 1583957758, 3763309577, 493123696, 780592180, 176468239, 1329032349, 3609623374, 734956914, 1884483001, 1177920190, 198346963, 3626028797, 1282987909, 1641518430, 868662499, 1388019710, 2344259898, 2518152987, 3916586844, 1485854782, 1997748114, 799065594, 2799018585, 3891712019, 3819786570, 887420462, 1420945805, 910348539, 1890029406, 1779941450, 126246865, 1290609213, 2556250476, 156001151, 2618976178, 3766583560, 1323932496, 2101678106, 2307583117, 2021169506, 2104181638, 1864171331, 1206350966, 139129898, 1872868344, 2602529641, 4274744181, 284774378, 3234054152, 1730996481, 3558114334, 801198866, 2065285037, 3182757731, 1058244612, 2704875913, 695465041, 4077033321, 4239835338, 1126647744, 752344413, 822587063, 770824953, 3313411895, 1011835720, 1128115455, 495577493, 2598725063, 4071514793, 3851300108, 3163875426, 872884951, 3493678917, 1189654272, 1382382869, 35866067, 1493582674, 2013883806, 2289110932, 4231654554, 2676790928, 701574000, 694761963, 3388570500, 2075481424, 1503005344, 3457051327, 2849643141, 2682410156, 3160380198, 4176311402, 3586855186, 596127797, 2408536078, 3338706890, 3989491476, 1000005130, 267726788, 2606490709, 2079562148, 990133887, 4212047548, 372683482, 423565605, 4206110512, 1641385630, 793718707, 2276852007, 145338824, 3165673658, 2246298937, 3598720248, 1515210630, 50058982, 2213611256, 2142834679, 4087169429, 535429941, 3734488325, 2049992511, 711205354, 1895190464, 2363464887, 1142307627, 111212467, 3559250549, 549102225, 4220213057, 1819020928, 1197987170, 2978395763, 3348576983, 870349943, 3568139464, 1655437981, 1088058025, 1268784554, 1465089546, 2241055893, 649004453, 2940211790, 2408521248, 19048566, 3682791466, 799394750, 2241560215, 1369583909, 2115672880, 2012277295, 3690353539, 1798238871, 3850134856, 1129720966, 3831433044, 1762436592, 1750126651, 2060909029, 2320376527, 2066296945, 2566062569, 1932566005, 3711313010, 2589552103, 1048331752, 1485675962, 3335205308, 852831296, 673510280, 582893437, 2886556496 };
		}

		public CryptoConstants()
		{
		}

		public static byte[] decodeBytes(byte[] bytes)
		{
			byte[] numArray = new byte[(int)bytes.Length];
			for (byte i = 0; i < (int)bytes.Length; i = (byte)(i + 1))
			{
				numArray[i] = (byte)(CryptoConstants.specKeys1[bytes[i]] - i);
			}
			return numArray;
		}

		public static byte[] decodeNewBytes(byte[] bytes)
		{
			return null;
		}

		public static byte[] encryptBytes(byte[] original)
		{
			byte[] numArray = new byte[(int)original.Length];
			for (byte i = 0; i < (int)original.Length; i = (byte)(i + 1))
			{
				numArray[i] = CryptoConstants.specKeys2[(i + original[i]) % 255];
			}
			return numArray;
		}

		public static uint GetKey(uint counter)
		{
			byte[] bytes = BitConverter.GetBytes(counter);
			uint thirdByteKeys = CryptoConstants.ThirdByte_Keys[bytes[3]] ^ CryptoConstants.SecondByte_Keys[bytes[2]] ^ CryptoConstants.FirstByte_Keys[bytes[1]] ^ CryptoConstants.ZeroByte_Keys[bytes[0]];
			return thirdByteKeys;
		}
	}
}